package com.hxd.otc.module.my.presenter;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.my.contract.ModifyLoginPasswordContract;
import com.hxd.otc.module.my.model.UserModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

/**
 * Created by lzy on 2018/6/12 0012.
 * description ${修改登录密码 Presenter}
 */
public class ModifyLoginPasswordPresenter extends BasePresenter<ModifyLoginPasswordContract.View> implements ModifyLoginPasswordContract.Presenter {


    private final UserModel mUserModel;

    public ModifyLoginPasswordPresenter(ModifyLoginPasswordContract.View view) {
        super(view);
        mUserModel = UserModel.getInstance();
    }

    @Override
    public void modifyLoginPassword(String password, String oldPassword) {
        mUserModel.updateLoginPassword(password, oldPassword, new BaseObserver<String>() {
            @Override
            public void onNext(String msg, String o) {
                mView.modifyLoginPasswordSuccess();
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean<String>>bindAutoDispose());
    }

}
